/*
 * HeatmapInternalFrame.java
 *
 * Created on 02.12.2009, 14:48:01
 */
package GUI.iFrames.HetmapFrameComponents;

import input.HEATMAP_BUFFER_IO;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Image;
import java.awt.Insets;
import java.awt.Point;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.io.File;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Vector;

import javax.swing.AbstractAction;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.KeyStroke;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.SwingConstants;

import org.jfree.chart.ChartMouseEvent;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.ChartRenderingInfo;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.annotations.AbstractXYAnnotation;
import org.jfree.chart.annotations.XYBoxAnnotation;
import org.jfree.chart.annotations.XYImageAnnotation;
import org.jfree.chart.annotations.XYLineAnnotation;
import org.jfree.chart.annotations.XYTextAnnotation;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.plot.CombinedDomainXYPlot;
import org.jfree.chart.plot.CombinedRangeXYPlot;
import org.jfree.chart.plot.Plot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.PlotRenderingInfo;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.PaintScale;
import org.jfree.chart.renderer.xy.XYBlockRenderer;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.data.Range;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.xy.DefaultXYZDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.jfree.ui.RectangleEdge;
import org.jfree.ui.TextAnchor;
import org.jfree.util.ShapeUtilities;

import toolz.IMS_CSV_File;
import toolz.ImageMethods;
import toolz.MyMath;
import toolz.PolarGlyphBuilder;
import toolz.internalFrameKeyRegister;
import toolz.netCdfTools;
import DATA.iDataSet;
import DATA.SubstanceDB.SubstanceDB;
import DATA.SubstanceDB.SubstanceDBItem;
import DATA.iDataSetParts.Measurement;
import DATA.iDataSetParts.Peak;
import DATA.iDataSetParts.Peaklist;
import DATA.iDataSetParts.SubstanceInfo;
import GUI.BaseFrame;
import GUI.ChartTools.BW_PaintScale;
import GUI.ChartTools.WBRG_PaintScale;
import GUI.iFrames.ChartInternalFrame;
import GUI.iFrames.DataSourceComponents.DataSourcesInternalFrame;

/**
 * 
 * @author Bunkowski
 */
public class HeatmapInternalFrame extends javax.swing.JInternalFrame implements MouseListener, MouseMotionListener, MouseWheelListener {

	public static final long serialVersionUID = 1L;

	private boolean BUFFER = true;
	final Font FONT = new Font("SansSerif", Font.BOLD, 12);
	private JFreeChart chart;
	private double[][] jfcmap;
	private double[][] alignedJFCmap;
	// private double[][] rawDataMap;//BEGIN 20.12.2011(Enable Rip position correction)
	double[][] rawDataMapAligned;
	double[] scaleK0;
	private double[] scaleRT;
	XYPlot heatmapPlot;
	XYPlot spectraplot, gcmsPlot;
	ChartPanel cp;
	private Range daLb = null, raLb = null;
	private Range tempx = null, tempy = null;
	iDataSet idataset;
	Measurement measurement;
	DataSourcesInternalFrame dsif;
	public XYBoxAnnotation alignAnno;
	private ArrayList<XYLineAnnotation> allPeaksAnnos = new ArrayList<XYLineAnnotation>();
	private ArrayList<XYLineAnnotation> thisPeakAnnotations = new ArrayList<XYLineAnnotation>();
	private boolean validCacheObjectFound = false;
	private ArrayList<AbstractXYAnnotation> substanceAnnotations = new ArrayList<AbstractXYAnnotation>();
	private double xStart = 0, yStart = 0;
	private boolean startSelected = false;
	private XYBoxAnnotation area = new XYBoxAnnotation(0, 0, 0, 0);
	XYLineAnnotation spectraDtPositionAnnotation, gcmsPositionAnno, movingtop, movingbot, movingrig, movinglef;
	double lastYmovedPosition = -1;
	private XYBlockRenderer xybr;
	private boolean showAllPeaklists = false;
	private Point2D panStartPoint;
	boolean showSpectraOnMouseover = true;
	XYSeriesCollection klickedpectraDds = new XYSeriesCollection();
	ArrayList<XYLineAnnotation> klickedSpectraAnnotations;
	ArrayList<XYLineAnnotation> klickedGcmsAnnotations;
	ArrayList<XYTextAnnotation> klickedGcmsTextAnnotations;
	private double amplify = 40;
	private CombinedDomainXYPlot cdp;
	private CombinedRangeXYPlot crp;
	ChartInternalFrame LiCh = null;
	XYTextAnnotation spectraPlotCoordinateText, gcmsPlotCoordinateText;
	double visibleRectRatio = 1.0;
	ChartMouseEvent lastEvent;
	Vector<String> gcmsFilenames = new Vector<String>(); // NO_UCD
	private double noiseLevel = 0.0020;
	boolean showHeatmapOnly = false;
	boolean showGcms = false;
	XYBoxAnnotation xyb = null;
	SubstanceInfo mouseOveredSubstance = null;
	boolean substanceEditingProcess = false;
	XYTextAnnotation movingTextannotation = null;
	private ChartInternalFrame extractedSpectraChart = null;
	XYImageAnnotation movingPolar;
	private boolean ripCompensation = true;
	private int spectraplotViewPercentage = 15;
	private HeatmapMouseActions hma;
	private double GcToMccAlign = 1;
	private double A = 7.92065;
	private double B = 2.60168;
	private double C = -2.58105;

	private void setupVariables() {
		klickedSpectraAnnotations = new ArrayList<XYLineAnnotation>();
		klickedGcmsAnnotations = new ArrayList<XYLineAnnotation>();
		klickedGcmsTextAnnotations = new ArrayList<XYTextAnnotation>();
	}

	public double getAmplify() {
		return amplify;
	}

	public HeatmapInternalFrame(DataSourcesInternalFrame dataSourcesInternalFrame, Point dropLocation) {

		// -Dsun.java2d.opengl=True

		this.dsif = dataSourcesInternalFrame;
		this.idataset = dataSourcesInternalFrame.idataset;

		initComponents();
		setupVariables();

		setFocusable(true);
		setVisible(true);
		setLocation((int) dropLocation.x - 10, (int) dropLocation.y - 60);
		setSize(800, 600);

		internalFrameKeyRegister keyRegister = new internalFrameKeyRegister(this);

		keyRegister.register("F1", fixAxisButton);
		keyRegister.register("F2", plsButton);
		keyRegister.register("F3", lichButton);

		keyRegister.register("ESCAPE", noneButton);
		keyRegister.register("1", addPeak);
		keyRegister.register("2", deletePeak);
		keyRegister.register("3", addSubstance);
		keyRegister.register("4", deleteSubstance);
		keyRegister.register("5", moveArea);
		getContentPane().setLayout(new BorderLayout(0, 0));
		getContentPane().add(bottomPanel, BorderLayout.NORTH);

		JLabel lblAmplify = new JLabel(" Amplify: ");
		bottomPanel.add(lblAmplify);
		heatLabel = new javax.swing.JLabel();
		bottomPanel.add(heatLabel);
		heatLabel.setHorizontalAlignment(SwingConstants.CENTER);

		heatLabel.setBackground(new java.awt.Color(255, 255, 0));
		heatLabel.setText("1.000");
		heatLabel.setOpaque(true);

		JLabel lblAlignRt = new JLabel(" Alignment RT: ");
		bottomPanel.add(lblAlignRt);
		alignRTValueLabel = new javax.swing.JLabel();
		bottomPanel.add(alignRTValueLabel);
		alignRTValueLabel.setHorizontalAlignment(SwingConstants.CENTER);
		alignRTValueLabel.setText("1.000");
		alignRTValueLabel.setOpaque(true);

		lblRipPosition = new JLabel(" Original RIP position: ");
		bottomPanel.add(lblRipPosition);

		alignK0ValueLabel = new JLabel("0.000");
		bottomPanel.add(alignK0ValueLabel);
		getContentPane().add(jScrollPane1, BorderLayout.WEST);
		getContentPane().add(center, BorderLayout.CENTER);

		getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("Q"), "q");
		getRootPane().getActionMap().put("q", new AbstractAction() {

			public static final long serialVersionUID = 1L;

			public void actionPerformed(java.awt.event.ActionEvent e) {
				spectraplotViewPercentage -= 2;
				updateHeatmap();

			}
		});

		getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("W"), "w");
		getRootPane().getActionMap().put("w", new AbstractAction() {

			public static final long serialVersionUID = 1L;

			public void actionPerformed(java.awt.event.ActionEvent e) {
				spectraplotViewPercentage += 2;
				updateHeatmap();

			}
		});

		getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("Y"), "y");
		getRootPane().getActionMap().put("y", new AbstractAction() {

			public static final long serialVersionUID = 1L;

			public void actionPerformed(java.awt.event.ActionEvent e) {
				visibleRectRatio -= 0.05;
				hma.chartMouseMoved(lastEvent);
			}
		});

		getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("X"), "x");
		getRootPane().getActionMap().put("x", new AbstractAction() {

			public static final long serialVersionUID = 1L;

			public void actionPerformed(java.awt.event.ActionEvent e) {
				visibleRectRatio += 0.05;
				hma.chartMouseMoved(lastEvent);
			}
		});
		getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("UP"), "UP");
		getRootPane().getActionMap().put("UP", new AbstractAction() {

			public static final long serialVersionUID = 1L;

			public void actionPerformed(java.awt.event.ActionEvent e) {
				int y = dsif.table.getSelectedRow();
				int x = dsif.table.getSelectedColumn();
				dsif.table.changeSelection(y - 1, x, false, false);
				dsif.showHeatmap();
				System.out.println("up");
			}
		});
		getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("DOWN"), "DOWN");
		getRootPane().getActionMap().put("DOWN", new AbstractAction() {

			public static final long serialVersionUID = 1L;

			public void actionPerformed(java.awt.event.ActionEvent e) {
				int y = dsif.table.getSelectedRow();
				int x = dsif.table.getSelectedColumn();
				dsif.table.changeSelection(y + 1, x, false, false);
				dsif.showHeatmap();
				System.out.println("down");
			}
		});
	}

	private void showSpectraPlot() {
		if (!showHeatmapOnly) {
			showSpectraOnMouseover = true;
			NumberAxis intensityAxis = new NumberAxis("intensity");
			intensityAxis.setNumberFormatOverride(new DecimalFormat("0.0000"));

			NumberAxis spectraK0axis = new NumberAxis("1/k0");
			spectraplot.setDomainAxis(spectraK0axis);
			spectraplot.setRangeAxis(intensityAxis);

			spectraplot.setDataset(null);
			XYLineAndShapeRenderer line = new XYLineAndShapeRenderer(true, false);
			spectraplot.setRenderer(line);
			cdp.add(spectraplot, spectraplotViewPercentage);
		}
	}

	private void showGcmsPlot() {
		if (!showHeatmapOnly) {
			showSpectraOnMouseover = false;
			NumberAxis xa = new NumberAxis("TIC");
			xa.setInverted(true);
			gcmsPlot.setDomainAxis(xa);

			double maxRt = scaleRT[scaleRT.length - 1];

			double rtFactor = 1;
			if (idataset.peaklists.containsKey(measurement.measurementID)) {
				Peaklist pl = idataset.peaklists.get(measurement.measurementID);
				rtFactor = pl.getRtFactor();
			} else {
				rtFactor = 1.0;
			}
			rtFactor = rtFactor * GcToMccAlign;

			XYSeriesCollection dataset = netCdfTools.getXYSeriesCollection(maxRt, measurement.gcmsFilePath, rtFactor, A, B, C);

			gcmsPlot.setDataset(dataset);

			gcmsPlot.setRenderer(new XYLineAndShapeRenderer(true, false));

			crp.add(gcmsPlot, 15);

			gcmsPlot.getDomainAxis().setAutoRange(false);
			gcmsPlot.getRangeAxis().setAutoRange(false);
			// for (SubstanceInfo si : idataset.substanceInfos) {
			// if (si.RtGc != -1) {
			// double xMax = gcmsPlot.getDomainAxis().getUpperBound();
			// double xMin = gcmsPlot.getDomainAxis().getLowerBound();
			// XYTextAnnotation xt = new XYTextAnnotation(si.name, xMin, netCdfTools.GcToMcc(si.RtGc)*rtFactor);
			// xt.setTextAnchor(TextAnchor.CENTER_RIGHT);
			// gcmsPlot.addAnnotation(xt);
			// }
			// }
		}
	}

	public void showHeatmap(Measurement measurement) {
		if (measurement == this.measurement) {
			System.out.println("!!WARNING!!: Preforming complete reload of same file (not needed ?)");
		}
		this.measurement = measurement;

		if (measurement.gcmsFilePath.equals("")) {
			showGcms = false;
			showGcmsToggleButton1.setSelected(false);
			showGcmsToggleButton1.setEnabled(false);
		} else {
			showGcmsToggleButton1.setEnabled(true);
		}

		String name = new File(measurement.path).getName() + " / " + measurement.patientID;
		this.setTitle(name);
		center.removeAll();

		// try to load from cache
		if (BUFFER) {
			loadFromCache();
		}

		// otherwise parse an compute new
		if (validCacheObjectFound == false) {
			IMS_CSV_File ims_file = new IMS_CSV_File(new File(measurement.path));
			loadFromFile(ims_file, false);
		}

		// show compensation spectra
		// Vector<Double> dataLine = new Vector<Double>();
		// for(double d : ImageMethods.compensationSpectra){
		// dataLine.add(d);
		// }
		// ChartInternalFrame cif = new ChartInternalFrame(dataLine);
		// cif.showAsLineChart();
		// cif.setSize(800, 600);
		// BaseFrame.applyFrame(cif);
		// compensation end

		alignedJFCmap = new double[jfcmap.length][jfcmap[0].length];
		rawDataMapAligned = new double[jfcmap.length][jfcmap[0].length];

		double rtFactor = 1.0;
		double ripPosition = 0;
		double k0Shift = 0;
		if (idataset.peaklists.containsKey(measurement.measurementID)) {
			Peaklist pl = idataset.peaklists.get(measurement.measurementID);
			try {
				rtFactor = pl.getRtFactor();
				// BEGIN 20.12.2011(Enable Rip position correction)
				ripPosition = pl.getOriginalRipPosition();
				k0Shift = pl.getK0Offset();
				// END
			} catch (Exception ex) {
			}
		}

		DecimalFormat factorFormat = new DecimalFormat("#0.000");
		alignRTValueLabel.setText(factorFormat.format(rtFactor));

		alignK0ValueLabel.setText(factorFormat.format(ripPosition));// 20.12.2011(Enable Rip position correction)

		// discretizing pixel for optimal visualization
		double avarageTimeDistance = rtFactor * scaleRT[scaleRT.length - 1] / (scaleRT.length);
		avarageTimeDistance = MyMath.round(avarageTimeDistance, 2);

		boolean discretize = false;

		ArrayList<Double> interpolationCheck = new ArrayList<Double>();

		for (int i = 0; i < jfcmap[0].length; i++) {
			alignedJFCmap[0][i] = jfcmap[0][i] + k0Shift;// 20.12.2011(Enable Rip position correction)
			alignedJFCmap[2][i] = jfcmap[2][i];
			if (discretize == false) {
				alignedJFCmap[1][i] = MyMath.round(jfcmap[1][i] * rtFactor, 3);
			} else {
				alignedJFCmap[1][i] = MyMath.discretize(jfcmap[1][i] * rtFactor, avarageTimeDistance);
				if (!interpolationCheck.contains(alignedJFCmap[1][i])) {
					interpolationCheck.add(alignedJFCmap[1][i]);
				}
			}
			// rawDataMapAligned[0][i] = jfcmap[0][i];
			// rawDataMapAligned[1][i] = Math.round((jfcmap[1][i] * rtFactor) * precision) / precision;
			// rawDataMapAligned[2][i] = rawDataMap[2][i];
		}
		rawDataMapAligned = alignedJFCmap;

		// if(discretize){
		// ArrayList<Double> spectraToInterpolate = new ArrayList<Double>();
		// for (int i = 1; i < scaleRT.length-1; i++) {
		// double j = i * avarageTimeDistance;
		// if (!interpolationCheck.contains(j)){
		// spectraToInterpolate.add(j);
		// }
		// }
		//
		// double[][] interpolatedJFCmap = new double[jfcmap.length][jfcmap[0].length+spectraToInterpolate.size()];
		// for (int i = 0; i < jfcmap[0].length; i++) {
		// interpolatedJFCmap[0][i] = alignedJFCmap[0][i];
		// interpolatedJFCmap[2][i] = alignedJFCmap[2][i];
		// interpolatedJFCmap[1][i] = alignedJFCmap[1][i];
		//
		// if(spectraToInterpolate.contains(alignedJFCmap[1][i]+avarageTimeDistance)){
		// interpolatedJFCmap[0][i] = alignedJFCmap[0][i];
		// interpolatedJFCmap[2][i] = alignedJFCmap[2][i];
		// interpolatedJFCmap[1][i] = alignedJFCmap[1][i-1]+avarageTimeDistance;
		// System.out.println("interpolating "+interpolatedJFCmap[1][i]+" with value from "+alignedJFCmap[1][i-1]);
		// i++;
		//
		// }
		// }
		// alignedJFCmap = interpolatedJFCmap;
		// }

		DefaultXYZDataset imsdds = new DefaultXYZDataset();
		imsdds.addSeries(name, alignedJFCmap);
		PaintScale ps = null;
		if (greyScale.isSelected()) {
			ps = new BW_PaintScale(0, amplify);
		} else {
			ps = new WBRG_PaintScale(0, amplify);
		}

		xybr = new XYBlockRenderer();
		xybr.setPaintScale(ps);
		xybr.setDataBoundsIncludesVisibleSeriesOnly(true);
		xybr.setBlockWidth((double) scaleK0[scaleK0.length - 1] / (double) scaleK0.length);
		xybr.setBlockHeight(avarageTimeDistance);

		System.out.println("Creating plot");
		NumberAxis RTaxis = new NumberAxis("RT");
		NumberAxis K0axis = new NumberAxis("1/k0");
		K0axis.setAutoTickUnitSelection(true);

		heatmapPlot = new XYPlot(imsdds, K0axis, RTaxis, xybr);

		if (greyScale.isSelected()) {
			heatmapPlot.setBackgroundPaint(Color.black);
			heatmapPlot.setDomainGridlinesVisible(false);
			heatmapPlot.setRangeGridlinesVisible(false);
		} else {
			heatmapPlot.setBackgroundPaint(Color.white);
			heatmapPlot.setDomainGridlinesVisible(true);
			heatmapPlot.setRangeGridlinesVisible(true);
		}

		// SPECTRAPLOT BEGINN

		if (!showGcms) {
			spectraplot = new XYPlot();
			cdp = new CombinedDomainXYPlot(heatmapPlot.getDomainAxis());
			cdp.add(heatmapPlot, 100 - spectraplotViewPercentage);
			// cdp.setRangeAxis(heatmapPlot.getRangeAxis());
			showSpectraPlot();
			chart = new JFreeChart(cdp);
		} else {// show gcms
			gcmsPlot = new XYPlot();
			crp = new CombinedRangeXYPlot(heatmapPlot.getRangeAxis());
			// crp.setDomainAxis(heatmapPlot.getRangeAxis());
			// crp.setOrientation(PlotOrientation.HORIZONTAL);
			showGcmsPlot();
			crp.add(heatmapPlot, 85);
			chart = new JFreeChart(crp);
		}

		// SPECTRAPLOT END

		chart.setAntiAlias(false);
		cp = new ChartPanel(chart);

		center.add(cp);

		hma = new HeatmapMouseActions(this);
		cp.addMouseListener(this);
		cp.addChartMouseListener(hma);
		cp.addMouseWheelListener(this);
		cp.addMouseMotionListener(this);
		// new SubstanceAssignmentHelper(cp);

		heatLabel.setText((xybr.getPaintScale().getUpperBound() + "    ").substring(0, 5));

		// if fixaxis is selected set to fixed axis
		if (raLb != null && daLb != null) {
			heatmapPlot.getRangeAxis().setRange(raLb);
			heatmapPlot.getDomainAxis().setRange(daLb);
		} else {
			// if a measurement is selected via a substance column
			// autoselect substance area from datasource
			SubstanceInfo s = dsif.getSelectedSubstance();
			if (!s.name.equals("")) {
				Point2D.Double p = new Point2D.Double(s.dt, s.rt);
				setAxisViewTo(p, s.dtTolerance * 15, s.rtTolerance * 5);
			} // if nothings selcted, set axis to min/max of scales
			else {
				heatmapPlot.getDomainAxis().setUpperBound(1.2);
				heatmapPlot.getDomainAxis().setLowerBound(0.3);
				heatmapPlot.getRangeAxis().setUpperBound(scaleRT[scaleRT.length - 1]);
				heatmapPlot.getRangeAxis().setLowerBound(scaleRT[0]);
			}
		}
		moveToFront();
		validate();

		HeatmapPopUpModifier.modify(cp.getPopupMenu());

		if (BUFFER) {
			saveToCache();
		}

	}

	public void mouseClicked(MouseEvent e) {
		// USE CHARTMOUSEKLICKED
	}

	public void mousePressed(MouseEvent e) {
		if (e.getButton() == 2) {
			cp.setDomainZoomable(false);
			cp.setRangeZoomable(false);
			Rectangle2D dataArea = cp.getScreenDataArea();
			Point2D point = e.getPoint();
			if (dataArea.contains(point)) {
				this.panStartPoint = point;
			}
		}
	}

	public void mouseReleased(MouseEvent e) {

		this.panStartPoint = null;
		cp.setDomainZoomable(true);
		cp.setRangeZoomable(true);

		if (startSelected) {
			try {
				heatmapPlot.removeAnnotation(area);
			} catch (Exception exc) {
			}
			Point2D.Double p = getXYonChart(e);
			area = new XYBoxAnnotation(xStart, p.getY(), p.getX(), yStart);
			heatmapPlot.addAnnotation(area);
			startSelected = false;
			heatmapPlot.getDomainAxis().setRange(tempx);
			heatmapPlot.getRangeAxis().setRange(tempy);
			showPeaklist();
		}
	}

	public void mouseDragged(MouseEvent e) {
		if (this.panStartPoint != null) {
			Rectangle2D scaledDataArea = this.cp.getScreenDataArea();

			this.panStartPoint = ShapeUtilities.getPointInRectangle(this.panStartPoint.getX(), this.panStartPoint.getY(), scaledDataArea);
			Point2D panEndPoint = ShapeUtilities.getPointInRectangle(e.getX(), e.getY(), scaledDataArea);

			// horizontal pan
			ValueAxis xAxis = heatmapPlot.getDomainAxis();

			if (xAxis != null) {
				double translatedStartPoint = xAxis.java2DToValue((float) this.panStartPoint.getX(), scaledDataArea,
						heatmapPlot.getDomainAxisEdge());
				double translatedEndPoint = xAxis
						.java2DToValue((float) panEndPoint.getX(), scaledDataArea, heatmapPlot.getDomainAxisEdge());
				double dX = translatedStartPoint - translatedEndPoint;

				double oldMin = xAxis.getLowerBound();
				double newMin = oldMin + dX;

				double oldMax = xAxis.getUpperBound();
				double newMax = oldMax + dX;

				xAxis.setLowerBound(newMin);
				xAxis.setUpperBound(newMax);
			}

			// vertical pan (1. Y-Axis)
			XYPlot vvp = heatmapPlot;
			ValueAxis yAxis = vvp.getRangeAxis();

			if (yAxis != null) {
				double translatedStartPoint = yAxis
						.java2DToValue((float) this.panStartPoint.getY(), scaledDataArea, vvp.getRangeAxisEdge());
				double translatedEndPoint = yAxis.java2DToValue((float) panEndPoint.getY(), scaledDataArea, vvp.getRangeAxisEdge());
				double dY = translatedStartPoint - translatedEndPoint;

				double oldMin = yAxis.getLowerBound();
				double newMin = oldMin + dY;

				double oldMax = yAxis.getUpperBound();
				double newMax = oldMax + dY;

				yAxis.setLowerBound(newMin);
				yAxis.setUpperBound(newMax);
			}

			// for the next time
			this.panStartPoint = panEndPoint;
		}
	}

	public void mouseMoved(MouseEvent e) {
		// USE CHARTMOUSEMOVED
	}

	public void mouseEntered(MouseEvent e) {
	}

	public void mouseExited(MouseEvent e) {
		try {
			spectraplot.removeAnnotation(spectraDtPositionAnnotation);
			spectraplot.removeAnnotation(spectraPlotCoordinateText);
		} catch (Exception x) {
		}

		try {
			gcmsPlot.removeAnnotation(gcmsPositionAnno);
			gcmsPlot.removeAnnotation(gcmsPlotCoordinateText);
		} catch (Exception x) {
		}
		try {
			heatmapPlot.removeAnnotation(movingtop);
			heatmapPlot.removeAnnotation(movingbot);
			heatmapPlot.removeAnnotation(movinglef);
			heatmapPlot.removeAnnotation(movingrig);
		} catch (Exception exc) {
		}
		if (klickedpectraDds.getSeriesCount() == 0) {
			spectraplot.setDataset(null);
		}
	}

	public void mouseWheelMoved(MouseWheelEvent e) {

		ValueAxis axis = null;
		if (showGcms) {
			axis = gcmsPlot.getDomainAxis();
		} else {
			axis = spectraplot.getRangeAxis();
		}

		if (e.isShiftDown()) {
			double step = 0.98;
			if (e.getWheelRotation() > 0) {
				step = 2 - step;
			}
			double oldmax = axis.getUpperBound();
			axis.setUpperBound(oldmax * step);
		} else if (e.isControlDown()) {
			double step = -axis.getUpperBound() * 0.02;
			if (e.getWheelRotation() > 0) {
				step *= -1;
			}
			double oldmax = axis.getLowerBound();
			axis.setLowerBound(oldmax + step);
		}
		if (e.isAltDown()) {
			if (e.getWheelRotation() > 0) {
				xybr.setPaintScale(new WBRG_PaintScale(0, xybr.getPaintScale().getUpperBound() + 1));
			} else {
				xybr.setPaintScale(new WBRG_PaintScale(0, xybr.getPaintScale().getUpperBound() - 1));
			}
			amplify = xybr.getPaintScale().getUpperBound();
			heatLabel.setText((xybr.getPaintScale().getUpperBound() + "    ").substring(0, 5));
		}
		if (!(e.isAltDown() || e.isControlDown() || e.isShiftDown())) {
			double xViewSize = heatmapPlot.getDomainAxis().getUpperBound() - heatmapPlot.getDomainAxis().getLowerBound();

			double yViewSize = heatmapPlot.getRangeAxis().getUpperBound() - heatmapPlot.getRangeAxis().getLowerBound();

			if (e.getWheelRotation() > 0) {
				xViewSize *= -1;
				yViewSize *= -1;

			} else {
			}

			heatmapPlot.getDomainAxis().setUpperBound(heatmapPlot.getDomainAxis().getUpperBound() - xViewSize / 20);
			heatmapPlot.getDomainAxis().setLowerBound(heatmapPlot.getDomainAxis().getLowerBound() + xViewSize / 20);
			heatmapPlot.getRangeAxis().setUpperBound(heatmapPlot.getRangeAxis().getUpperBound() - yViewSize / 20);
			heatmapPlot.getRangeAxis().setLowerBound(heatmapPlot.getRangeAxis().getLowerBound() + yViewSize / 20);
			hma.chartMouseMoved(lastEvent);

		}
	}

	private void setAxisViewTo(Point2D.Double p, double xViewSize, double yViewSize) {
		heatmapPlot.getDomainAxis().setUpperBound(p.getX() + xViewSize);
		heatmapPlot.getDomainAxis().setLowerBound(p.getX() - xViewSize);
		heatmapPlot.getRangeAxis().setUpperBound(p.getY() + yViewSize);
		heatmapPlot.getRangeAxis().setLowerBound(p.getY() - yViewSize);
	}

	private Point2D.Double getXYonChart(MouseEvent e) {
		XYPlot xyp = (XYPlot) heatmapPlot;
		Point2D p = cp.translateScreenToJava2D(e.getPoint());
		PlotOrientation orientation = xyp.getOrientation();
		RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(xyp.getDomainAxisLocation(), orientation);
		RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(xyp.getRangeAxisLocation(), orientation);

		ValueAxis domain = xyp.getDomainAxis();
		ValueAxis range = xyp.getRangeAxis();
		ChartRenderingInfo cri = cp.getChartRenderingInfo();
		int heatmapSubPlot = 0;
		if (showGcms) {
			heatmapSubPlot = 1;
		}
		if (showHeatmapOnly) {
			heatmapSubPlot = 0;
		}
		PlotRenderingInfo pri = cri.getPlotInfo().getSubplotInfo(heatmapSubPlot);
		double x = domain.java2DToValue(p.getX(), pri.getDataArea(), domainEdge);
		double y = range.java2DToValue(p.getY(), pri.getDataArea(), rangeEdge);

		x = Math.rint(x * 10000) / 10000.0;
		y = Math.rint(y * 100) / 100.0;
		return new Point2D.Double(x, y);
	}

	private void loadFromFile(IMS_CSV_File ims_file, boolean useDTAxis) {
		Vector<?> wrap = HEATMAP_BUFFER_IO.loadFromFileWithNoiselevel(ims_file, noiseLevel, ripCompensationCheckBox.isSelected(),
				medianFilter.isSelected(), sgFilter.isSelected(), gaussFilter.isSelected());
		jfcmap = (double[][]) wrap.get(0);
		// rawDataMap = (double[][]) wrap.get(1); //BEGIN 20.12.2011(Enable Rip position correction)
		scaleK0 = (double[]) wrap.get(2);
		scaleRT = (double[]) wrap.get(3);

	}

	private void loadFromCache() {
		Vector<?> wrap = HEATMAP_BUFFER_IO.loadFromCache(measurement);
		if (wrap.size() > 0) {
			jfcmap = (double[][]) wrap.get(0);
			// rawDataMap = (double[][]) wrap.get(1);//BEGIN 20.12.2011(Enable Rip position correction)
			scaleK0 = (double[]) wrap.get(2);
			scaleRT = (double[]) wrap.get(3);
			validCacheObjectFound = true;
		} else {
			validCacheObjectFound = false;
		}
	}

	private void saveToCache() {
		String chachedFileName = new File(measurement.path).getName().replace(".csv", ".cca");
		if (!new File("ChartCache/" + chachedFileName).exists()) {
			Vector<Object> wrap = new Vector<Object>();
			wrap.add(jfcmap);
			// wrap.add(rawDataMap);raw map not needed anymore [old]
			wrap.add(jfcmap); // dummy to retain structure [new]
			wrap.add(scaleK0);
			wrap.add(scaleRT);
			HEATMAP_BUFFER_IO.saveToCache(wrap, chachedFileName);
		}
	}

	// public void registerIDS(iDataSet idataset) {
	// this.idataset = idataset;
	// }
	public void setSelectedMeasurement(Measurement measurement) {
		this.measurement = measurement;
		showPeaklist();
		showSubstanceInfos();
	}

	public void updateHeatmap() {
		// retain axis
		System.out.println("Performing full heatmap update");
		Range ra = heatmapPlot.getRangeAxis().getRange();
		Range da = heatmapPlot.getDomainAxis().getRange();
		showHeatmap(measurement);
		heatmapPlot.getRangeAxis().setRange(ra);
		heatmapPlot.getDomainAxis().setRange(da);
		showPeaklist();
		showSubstanceInfos();
	}

	public void showSubstanceInfos() {
		for (Object obj : substanceAnnotations) {
			try {
				if (obj instanceof XYLineAnnotation) {
					heatmapPlot.removeAnnotation((XYLineAnnotation) obj);
				} else if (obj instanceof XYTextAnnotation) {
					heatmapPlot.removeAnnotation((XYTextAnnotation) obj);
				}

			} catch (Exception ex) {
			}
		}

		substanceAnnotations.clear();

		if (showSubstanceAnnotationsCheckBox.isSelected()) {
			for (int i = 0; i < idataset.substanceInfos.size(); i++) {
				SubstanceInfo s = idataset.substanceInfos.elementAt(i);
				double alignedRT = s.rt;
				// XYBoxAnnotation xyb = new XYBoxAnnotation(s.dt - s.dtTolerance, alignedRT - s.rtTolerance, s.dt +
				// s.dtTolerance, alignedRT + s.rtTolerance);

				XYLineAnnotation top = new XYLineAnnotation(s.dt - s.dtTolerance, alignedRT + s.rtTolerance, s.dt + s.dtTolerance,
						alignedRT + s.rtTolerance);
				XYLineAnnotation bot = new XYLineAnnotation(s.dt - s.dtTolerance, alignedRT - s.rtTolerance, s.dt + s.dtTolerance,
						alignedRT - s.rtTolerance);
				XYLineAnnotation rig = new XYLineAnnotation(s.dt + s.dtTolerance, alignedRT + s.rtTolerance, s.dt + s.dtTolerance,
						alignedRT - s.rtTolerance);
				XYLineAnnotation lef = new XYLineAnnotation(s.dt - s.dtTolerance, alignedRT + s.rtTolerance, s.dt - s.dtTolerance,
						alignedRT - s.rtTolerance);

				heatmapPlot.addAnnotation(top);
				heatmapPlot.addAnnotation(bot);
				heatmapPlot.addAnnotation(lef);
				heatmapPlot.addAnnotation(rig);
				XYTextAnnotation xyt = new XYTextAnnotation(s.name, s.dt, alignedRT + s.rtTolerance);
				xyt.setFont(FONT);
				xyt.setTextAnchor(TextAnchor.BOTTOM_CENTER);
				heatmapPlot.addAnnotation(xyt);
				substanceAnnotations.add(top);
				substanceAnnotations.add(bot);
				substanceAnnotations.add(lef);
				substanceAnnotations.add(rig);

				substanceAnnotations.add(xyt);
			}
		}
	}

	public void showAlignAnno(boolean show) {
		if (show) {
			heatmapPlot.addAnnotation(alignAnno);
		} else {
			try {
				heatmapPlot.removeAnnotation(alignAnno);
			} catch (Exception ex) {
			}
		}
	}

	public void showPeaklist() {
		for (int i = 0; i < thisPeakAnnotations.size(); i++) {
			heatmapPlot.removeAnnotation(thisPeakAnnotations.get(i));
		}
		if (showPeaklistCheckBox.isSelected()) {
			if (idataset.peaklists.containsKey(measurement.measurementID)) {
				Peaklist peaklist = idataset.peaklists.get(measurement.measurementID);
				for (Peak p : peaklist.getPeaks()) {
					// XYTextAnnotation xyt = new XYTextAnnotation("peak", p.dt, p.rt + 5);
					// xyt.setTextAnchor(TextAnchor.BOTTOM_LEFT);

					XYLineAnnotation xyRtLine = new XYLineAnnotation(p.dt - p.dtSize / 2, p.rt, p.dt + p.dtSize / 2, p.rt);
					XYLineAnnotation xyDtLine = new XYLineAnnotation(p.dt, p.rt - p.rtSize / 2, p.dt, p.rt + p.rtSize / 2);

					// chart.getXYPlot().addAnnotation(xyt);
					heatmapPlot.addAnnotation(xyDtLine);
					heatmapPlot.addAnnotation(xyRtLine);
					thisPeakAnnotations.add(xyDtLine);
					thisPeakAnnotations.add(xyRtLine);
				}
			}
		}
	}

	private void fixAxis(boolean fix) {
		if (fix) {
			daLb = heatmapPlot.getDomainAxis().getRange();
			raLb = heatmapPlot.getRangeAxis().getRange();
			System.out.println("fixing axis");
		} else {
			daLb = null;
			raLb = null;
			setSelectedMeasurement(measurement);
			System.out.println("unfixing axis");
		}
	}

	public void showAllPeaklistsToggle() {
		for (int i = 0; i < allPeaksAnnos.size(); i++) {
			heatmapPlot.removeAnnotation(allPeaksAnnos.get(i));
		}
		allPeaksAnnos.clear();

		if (showAllPeaklists) {
			System.out.println("plotting all peaklists");
			for (Peaklist pl : idataset.peaklists.values()) {
				for (Peak p : pl.getPeaks()) {
					// XYTextAnnotation xyt = new XYTextAnnotation("peak", p.dt, p.rt + 5);
					// xyt.setTextAnchor(TextAnchor.BOTTOM_LEFT);

					double alignedRT = p.rt;

					XYLineAnnotation xyRtLine = new XYLineAnnotation(p.dt - p.dtSize / 2, alignedRT, p.dt + p.dtSize / 2, alignedRT);
					XYLineAnnotation xyDtLine = new XYLineAnnotation(p.dt, alignedRT - p.rtSize / 2, p.dt, alignedRT + p.rtSize / 2);

					allPeaksAnnos.add(xyDtLine);
					allPeaksAnnos.add(xyRtLine);
					// chart.getXYPlot().addAnnotation(xyt);
					heatmapPlot.addAnnotation(xyDtLine);
					heatmapPlot.addAnnotation(xyRtLine);
				}
			}
		}
	}

	/**
	 * This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The content of this
	 * method is always regenerated by the Form Editor.
	 */
	private void initComponents() {

		buttonGroup1 = new javax.swing.ButtonGroup();
		optionsPopupMenu = new javax.swing.JPopupMenu();
		showPeaklistCheckBox = new javax.swing.JCheckBoxMenuItem();
		showSubstanceAnnotationsCheckBox = new javax.swing.JCheckBoxMenuItem();
		filterMenu = new javax.swing.JMenu();
		ripCompensationCheckBox = new javax.swing.JCheckBoxMenuItem();
		medianFilter = new javax.swing.JCheckBoxMenuItem();
		sgFilter = new javax.swing.JCheckBoxMenuItem();
		gaussFilter = new javax.swing.JCheckBoxMenuItem();
		determNoiseLevelMenuItem = new javax.swing.JMenuItem();
		noiseLevelMenu = new javax.swing.JMenu();
		MenuItem0000 = new javax.swing.JMenuItem();
		MenuItem0005 = new javax.swing.JMenuItem();
		MenuItem0010 = new javax.swing.JMenuItem();
		MenuItem0015 = new javax.swing.JMenuItem();
		MenuItem0020 = new javax.swing.JMenuItem();
		MenuItem0025 = new javax.swing.JMenuItem();
		MenuItem0030 = new javax.swing.JMenuItem();
		SubstanceDBMenu = new javax.swing.JMenu();
		identifyMccImsPeaksMenuItem = new javax.swing.JMenuItem();
		identifyMccImsPeaksMenuItem1 = new javax.swing.JMenuItem();
		showHeatmapOnlyMenuItem = new javax.swing.JCheckBoxMenuItem();
		PolarGlyphMenuItem = new javax.swing.JCheckBoxMenuItem();
		livePolarGlyphMenuItem = new javax.swing.JCheckBoxMenuItem();
		updateMenuItem = new javax.swing.JMenuItem();
		greyScale = new javax.swing.JCheckBoxMenuItem();
		areaOnHeatmapMenu = new javax.swing.JPopupMenu();
		deleteAreaMenuItem = new javax.swing.JMenuItem();
		jSeparator1 = new javax.swing.JSeparator();
		closeareaOnHeatmap = new javax.swing.JCheckBoxMenuItem();
		center = new javax.swing.JPanel();
		jScrollPane1 = new javax.swing.JScrollPane();
		leftPanel = new javax.swing.JPanel();
		leftPanel.setAlignmentY(Component.TOP_ALIGNMENT);
		leftPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
		optionsLabel = new javax.swing.JLabel();
		viewPanel = new javax.swing.JPanel();
		fixAxisButton = new javax.swing.JToggleButton();
		plsButton = new javax.swing.JToggleButton();
		lichButton = new javax.swing.JToggleButton();
		mousePanel = new javax.swing.JPanel();
		addPeak = new javax.swing.JToggleButton();
		deletePeak = new javax.swing.JToggleButton();
		addSubstance = new javax.swing.JToggleButton();
		deleteSubstance = new javax.swing.JToggleButton();
		noneButton = new javax.swing.JToggleButton();
		moveArea = new javax.swing.JToggleButton();
		gcmsPanel = new javax.swing.JPanel();
		showGcmsToggleButton1 = new javax.swing.JToggleButton();
		aPanel = new javax.swing.JPanel();
		aPlus = new javax.swing.JButton();
		jLabel1 = new javax.swing.JLabel();
		aMinus = new javax.swing.JButton();
		bPanel = new javax.swing.JPanel();
		bPlus = new javax.swing.JButton();
		jLabel2 = new javax.swing.JLabel();
		bMinus = new javax.swing.JButton();
		cPanel = new javax.swing.JPanel();
		cPlus = new javax.swing.JButton();
		jLabel3 = new javax.swing.JLabel();
		cMinus = new javax.swing.JButton();
		Afield = new javax.swing.JTextField();
		Bfield = new javax.swing.JTextField();
		Cfield = new javax.swing.JTextField();
		extractButton = new javax.swing.JButton();

		showPeaklistCheckBox.setSelected(true);
		showPeaklistCheckBox.setText("Show peaklist");
		showPeaklistCheckBox.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				showPeaklist();
			}
		});
		optionsPopupMenu.add(showPeaklistCheckBox);

		showSubstanceAnnotationsCheckBox.setSelected(true);
		showSubstanceAnnotationsCheckBox.setText("Show Annotations");
		showSubstanceAnnotationsCheckBox.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				showSubstanceInfos();
			}
		});
		optionsPopupMenu.add(showSubstanceAnnotationsCheckBox);

		filterMenu.setText("Filter Options");

		ripCompensationCheckBox.setSelected(true);
		ripCompensationCheckBox.setText("RIP Compensation (recommended)");
		ripCompensationCheckBox.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				ripCompensation = ripCompensationCheckBox.isSelected();
			}
		});
		filterMenu.add(ripCompensationCheckBox);

		medianFilter.setSelected(true);
		medianFilter.setText("Median Filter");
		medianFilter.setContentAreaFilled(false);
		medianFilter.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
		filterMenu.add(medianFilter);

		sgFilter.setSelected(true);
		sgFilter.setText("Sawitky-Golay Filter");
		filterMenu.add(sgFilter);

		gaussFilter.setSelected(true);
		gaussFilter.setText("Gauss filter");
		filterMenu.add(gaussFilter);

		determNoiseLevelMenuItem.setText("Determ noise level");
		determNoiseLevelMenuItem.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				determNoiseLevelMenuItemActionPerformed(evt);
			}
		});
		filterMenu.add(determNoiseLevelMenuItem);

		optionsPopupMenu.add(filterMenu);

		noiseLevelMenu.setText("Set noise level");

		MenuItem0000.setText("0.0000");
		MenuItem0000.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				MenuItem0000ActionPerformed(evt);
			}
		});
		noiseLevelMenu.add(MenuItem0000);

		MenuItem0005.setText("0.0005");
		MenuItem0005.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				MenuItem0005ActionPerformed(evt);
			}
		});
		noiseLevelMenu.add(MenuItem0005);

		MenuItem0010.setText("0.0010");
		MenuItem0010.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				MenuItem0010ActionPerformed(evt);
			}
		});
		noiseLevelMenu.add(MenuItem0010);

		MenuItem0015.setText("0.0015");
		MenuItem0015.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				MenuItem0015ActionPerformed(evt);
			}
		});
		noiseLevelMenu.add(MenuItem0015);

		MenuItem0020.setFont(new java.awt.Font("Tahoma", 1, 15));
		MenuItem0020.setText("0.0020 (default)");
		MenuItem0020.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				MenuItem0020ActionPerformed(evt);
			}
		});
		noiseLevelMenu.add(MenuItem0020);

		MenuItem0025.setText("0.0025");
		MenuItem0025.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				MenuItem0025ActionPerformed(evt);
			}
		});
		noiseLevelMenu.add(MenuItem0025);

		MenuItem0030.setText("0.0030");
		MenuItem0030.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				MenuItem0030ActionPerformed(evt);
			}
		});
		noiseLevelMenu.add(MenuItem0030);

		optionsPopupMenu.add(noiseLevelMenu);

		SubstanceDBMenu.setText("Substance DB");

		identifyMccImsPeaksMenuItem.setText("Identify detected MCC/IMS Peaks (multiple per peak)");
		identifyMccImsPeaksMenuItem.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				identifyMccImsPeaksMenuItemActionPerformed(evt);
			}
		});
		SubstanceDBMenu.add(identifyMccImsPeaksMenuItem);

		identifyMccImsPeaksMenuItem1.setText("Identify detected MCC/IMS Peaks (closest 1/k0 entry)");
		identifyMccImsPeaksMenuItem1.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				identifyMccImsPeaksMenuItem1ActionPerformed(evt);
			}
		});
		SubstanceDBMenu.add(identifyMccImsPeaksMenuItem1);

		optionsPopupMenu.add(SubstanceDBMenu);

		showHeatmapOnlyMenuItem.setText("show heatmap only");
		showHeatmapOnlyMenuItem.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				showHeatmapOnlyMenuItemActionPerformed(evt);
			}
		});
		optionsPopupMenu.add(showHeatmapOnlyMenuItem);

		PolarGlyphMenuItem.setText("PolarGlyph");
		PolarGlyphMenuItem.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				PolarGlyphMenuItemActionPerformed(evt);
			}
		});
		optionsPopupMenu.add(PolarGlyphMenuItem);

		livePolarGlyphMenuItem.setText("Live PolarGlyph");
		optionsPopupMenu.add(livePolarGlyphMenuItem);

		updateMenuItem.setText("Update heatmap");
		updateMenuItem.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				updateMenuItemActionPerformed(evt);
			}
		});
		optionsPopupMenu.add(updateMenuItem);

		greyScale.setText("Grey Scale");
		greyScale.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				greyScaleActionPerformed(evt);
			}
		});
		optionsPopupMenu.add(greyScale);

		deleteAreaMenuItem.setText("jMenuItem1");
		deleteAreaMenuItem.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				deleteAreaMenuItemActionPerformed(evt);
			}
		});
		areaOnHeatmapMenu.add(deleteAreaMenuItem);
		areaOnHeatmapMenu.add(jSeparator1);

		closeareaOnHeatmap.setSelected(true);
		closeareaOnHeatmap.setText("jCheckBoxMenuItem1");
		areaOnHeatmapMenu.add(closeareaOnHeatmap);

		setClosable(true);
		setIconifiable(true);
		setMaximizable(true);
		setResizable(true);
		setTitle("Heatmap Plot");
		addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
			public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
			}

			public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
			}

			public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
				closingevent(evt);
			}

			public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
			}

			public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
			}

			public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
			}

			public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
			}
		});

		center.setLayout(new javax.swing.BoxLayout(center, javax.swing.BoxLayout.Y_AXIS));

		jScrollPane1.setBorder(null);
		jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

		optionsLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		optionsLabel.setText("Options");
		optionsLabel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
		optionsLabel.addMouseListener(new java.awt.event.MouseAdapter() {
			public void mouseClicked(java.awt.event.MouseEvent evt) {
				optionsLabelMouseClicked(evt);
			}
		});

		viewPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("view"));

		fixAxisButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/fixAxis.png"))); // NOI18N
		fixAxisButton.setToolTipText("Fix axis [F1]");
		fixAxisButton.setMargin(new java.awt.Insets(2, 3, 2, 3));
		fixAxisButton.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/fixAxisSelected.png"))); // NOI18N
		fixAxisButton.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				fixAxisButtonActionPerformed(evt);
			}
		});
		fixAxisButton.addKeyListener(new java.awt.event.KeyAdapter() {
			public void keyReleased(java.awt.event.KeyEvent evt) {
				HeatmapInternalFrame.this.keyReleased(evt);
			}
		});

		plsButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/allPeaklists.png"))); // NOI18N
		plsButton.setToolTipText("Show peaklists from all measurements [F2]");
		plsButton.setMargin(new java.awt.Insets(2, 3, 2, 3));
		plsButton.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/allPeaklistsSelected.png"))); // NOI18N
		plsButton.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				plsButtonActionPerformed(evt);
			}
		});
		plsButton.addKeyListener(new java.awt.event.KeyAdapter() {
			public void keyReleased(java.awt.event.KeyEvent evt) {
				HeatmapInternalFrame.this.keyReleased(evt);
			}
		});

		lichButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/liveChart.png"))); // NOI18N
		lichButton.setToolTipText("Open live chart [F3]");
		lichButton.setMargin(new java.awt.Insets(2, 3, 2, 3));
		lichButton.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/liveChartSelected.png"))); // NOI18N
		lichButton.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				lichButtonActionPerformed(evt);
			}
		});
		lichButton.addKeyListener(new java.awt.event.KeyAdapter() {
			public void keyReleased(java.awt.event.KeyEvent evt) {
				HeatmapInternalFrame.this.keyReleased(evt);
			}
		});

		javax.swing.GroupLayout gl_viewPanel = new javax.swing.GroupLayout(viewPanel);
		viewPanel.setLayout(gl_viewPanel);
		gl_viewPanel.setHorizontalGroup(gl_viewPanel.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addComponent(fixAxisButton).addComponent(plsButton).addComponent(lichButton));
		gl_viewPanel.setVerticalGroup(gl_viewPanel.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				gl_viewPanel.createSequentialGroup().addComponent(fixAxisButton)
						.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(plsButton)
						.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(lichButton)));

		mousePanel.setBorder(javax.swing.BorderFactory.createTitledBorder("mouse"));

		buttonGroup1.add(addPeak);
		addPeak.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/peakPlus20.png"))); // NOI18N
		addPeak.setToolTipText("Add peaks [1]");
		addPeak.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
		addPeak.setMargin(new java.awt.Insets(2, 3, 2, 3));
		addPeak.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/peakPlus20Selectet.png"))); // NOI18N
		addPeak.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
		addPeak.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				addPeakActionPerformed(evt);
			}
		});
		addPeak.addKeyListener(new java.awt.event.KeyAdapter() {
			public void keyReleased(java.awt.event.KeyEvent evt) {
				HeatmapInternalFrame.this.keyReleased(evt);
			}
		});

		buttonGroup1.add(deletePeak);
		deletePeak.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/peakMinus20.png"))); // NOI18N
		deletePeak.setToolTipText("Delete peaks [2]");
		deletePeak.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
		deletePeak.setMargin(new java.awt.Insets(2, 3, 2, 3));
		deletePeak.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/peakMinus20Selected.png"))); // NOI18N
		deletePeak.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				deletePeakActionPerformed(evt);
			}
		});
		deletePeak.addKeyListener(new java.awt.event.KeyAdapter() {
			public void keyReleased(java.awt.event.KeyEvent evt) {
				HeatmapInternalFrame.this.keyReleased(evt);
			}
		});

		buttonGroup1.add(addSubstance);
		addSubstance.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/areaPlus20.png"))); // NOI18N
		addSubstance.setToolTipText("Add area [3]");
		addSubstance.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
		addSubstance.setMargin(new java.awt.Insets(2, 3, 2, 3));
		addSubstance.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/areaPlus20Selected.png"))); // NOI18N
		addSubstance.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				addSubstanceActionPerformed(evt);
			}
		});
		addSubstance.addKeyListener(new java.awt.event.KeyAdapter() {
			public void keyReleased(java.awt.event.KeyEvent evt) {
				HeatmapInternalFrame.this.keyReleased(evt);
			}
		});

		buttonGroup1.add(deleteSubstance);
		deleteSubstance.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/areaMinus20.png"))); // NOI18N
		deleteSubstance.setToolTipText("Delete area [4]");
		deleteSubstance.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
		deleteSubstance.setMargin(new java.awt.Insets(2, 3, 2, 3));
		deleteSubstance.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/areaMinus20Selected.png"))); // NOI18N
		deleteSubstance.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				deleteSubstanceActionPerformed(evt);
			}
		});
		deleteSubstance.addKeyListener(new java.awt.event.KeyAdapter() {
			public void keyReleased(java.awt.event.KeyEvent evt) {
				HeatmapInternalFrame.this.keyReleased(evt);
			}
		});

		buttonGroup1.add(noneButton);
		noneButton.setFont(new java.awt.Font("Tahoma", 1, 11));
		noneButton.setSelected(true);
		noneButton.setText("no");
		noneButton.setToolTipText("No mouse actions [Esc]");
		noneButton.setMargin(new java.awt.Insets(2, 3, 2, 3));
		noneButton.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				noneButtonActionPerformed(evt);
			}
		});
		noneButton.addKeyListener(new java.awt.event.KeyAdapter() {
			public void keyReleased(java.awt.event.KeyEvent evt) {
				HeatmapInternalFrame.this.keyReleased(evt);
			}
		});

		buttonGroup1.add(moveArea);
		moveArea.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/areaMove20.png"))); // NOI18N
		moveArea.setToolTipText("Move area [5]");
		moveArea.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
		moveArea.setMargin(new java.awt.Insets(2, 3, 2, 3));
		moveArea.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/areaMove20Selected.png"))); // NOI18N
		moveArea.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				moveAreaActionPerformed(evt);
			}
		});
		moveArea.addKeyListener(new java.awt.event.KeyAdapter() {
			public void keyReleased(java.awt.event.KeyEvent evt) {
				HeatmapInternalFrame.this.keyReleased(evt);
			}
		});

		javax.swing.GroupLayout gl_mousePanel = new javax.swing.GroupLayout(mousePanel);
		mousePanel.setLayout(gl_mousePanel);
		gl_mousePanel.setHorizontalGroup(gl_mousePanel.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(
						gl_mousePanel
								.createSequentialGroup()
								.addGroup(
										gl_mousePanel
												.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
												.addComponent(noneButton, javax.swing.GroupLayout.Alignment.LEADING,
														javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
														Short.MAX_VALUE)
												.addComponent(deletePeak, javax.swing.GroupLayout.Alignment.LEADING,
														javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
														Short.MAX_VALUE)
												.addComponent(addPeak, javax.swing.GroupLayout.Alignment.LEADING)
												.addComponent(addSubstance, javax.swing.GroupLayout.Alignment.LEADING,
														javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
														Short.MAX_VALUE)
												.addComponent(deleteSubstance, javax.swing.GroupLayout.Alignment.LEADING,
														javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
														Short.MAX_VALUE)
												.addComponent(moveArea, javax.swing.GroupLayout.Alignment.LEADING,
														javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
														Short.MAX_VALUE)).addContainerGap()));
		gl_mousePanel.setVerticalGroup(gl_mousePanel.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				gl_mousePanel
						.createSequentialGroup()
						.addComponent(addPeak)
						.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
						.addComponent(deletePeak)
						.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
						.addComponent(addSubstance)
						.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
						.addComponent(deleteSubstance)
						.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE,
								Short.MAX_VALUE).addComponent(moveArea).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
						.addComponent(noneButton)));

		gcmsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("gc/ms"));

		showGcmsToggleButton1.setText("show");
		showGcmsToggleButton1.setMargin(new Insets(1, 1, 1, 1));
		showGcmsToggleButton1.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				showGcmsToggleButton1ActionPerformed(evt);
			}
		});

		aPlus.setText("+");
		aPlus.setMargin(new java.awt.Insets(2, 2, 2, 2));
		aPlus.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				aPlusActionPerformed(evt);
			}
		});

		jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		jLabel1.setText("A");

		aMinus.setText("-");
		aMinus.setMargin(new java.awt.Insets(2, 2, 2, 2));
		aMinus.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				aMinusActionPerformed(evt);
			}
		});

		javax.swing.GroupLayout gl_aPanel = new javax.swing.GroupLayout(aPanel);
		aPanel.setLayout(gl_aPanel);
		gl_aPanel.setHorizontalGroup(gl_aPanel
				.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addComponent(aMinus, javax.swing.GroupLayout.DEFAULT_SIZE, 17, Short.MAX_VALUE)
				.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 17, Short.MAX_VALUE)
				.addComponent(aPlus, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE,
						javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
		gl_aPanel.setVerticalGroup(gl_aPanel.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				gl_aPanel.createSequentialGroup().addComponent(aPlus).addGap(0, 0, 0).addComponent(jLabel1).addGap(0, 0, 0)
						.addComponent(aMinus)));

		bPlus.setText("+");
		bPlus.setMargin(new java.awt.Insets(2, 2, 2, 2));
		bPlus.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				bPlusActionPerformed(evt);
			}
		});

		jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		jLabel2.setText("B");

		bMinus.setText("-");
		bMinus.setMargin(new java.awt.Insets(2, 2, 2, 2));
		bMinus.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				bMinusActionPerformed(evt);
			}
		});

		javax.swing.GroupLayout gl_bPanel = new javax.swing.GroupLayout(bPanel);
		bPanel.setLayout(gl_bPanel);
		gl_bPanel.setHorizontalGroup(gl_bPanel
				.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addComponent(bMinus, javax.swing.GroupLayout.DEFAULT_SIZE, 17, Short.MAX_VALUE)
				.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 17, Short.MAX_VALUE)
				.addComponent(bPlus, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE,
						javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
		gl_bPanel.setVerticalGroup(gl_bPanel.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				gl_bPanel.createSequentialGroup().addComponent(bPlus).addGap(0, 0, 0).addComponent(jLabel2).addGap(0, 0, 0)
						.addComponent(bMinus)));

		cPlus.setText("+");
		cPlus.setMargin(new java.awt.Insets(2, 2, 2, 2));
		cPlus.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				cPlusActionPerformed(evt);
			}
		});

		jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		jLabel3.setText("C");

		cMinus.setText("-");
		cMinus.setMargin(new java.awt.Insets(2, 2, 2, 2));
		cMinus.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				cMinusActionPerformed(evt);
			}
		});

		javax.swing.GroupLayout gl_cPanel = new javax.swing.GroupLayout(cPanel);
		cPanel.setLayout(gl_cPanel);
		gl_cPanel.setHorizontalGroup(gl_cPanel
				.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addComponent(cMinus, javax.swing.GroupLayout.DEFAULT_SIZE, 17, Short.MAX_VALUE)
				.addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 17, Short.MAX_VALUE)
				.addComponent(cPlus, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE,
						javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
		gl_cPanel.setVerticalGroup(gl_cPanel.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				gl_cPanel.createSequentialGroup().addComponent(cPlus).addGap(0, 0, 0).addComponent(jLabel3).addGap(0, 0, 0)
						.addComponent(cMinus)));

		javax.swing.GroupLayout gl_gcmsPanel = new javax.swing.GroupLayout(gcmsPanel);
		gcmsPanel.setLayout(gl_gcmsPanel);
		gl_gcmsPanel.setHorizontalGroup(gl_gcmsPanel
				.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addComponent(showGcmsToggleButton1)
				.addGroup(
						gl_gcmsPanel
								.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
								.addComponent(Cfield, javax.swing.GroupLayout.Alignment.LEADING)
								.addComponent(Bfield, javax.swing.GroupLayout.Alignment.LEADING)
								.addComponent(Afield, javax.swing.GroupLayout.Alignment.LEADING)
								.addGroup(
										javax.swing.GroupLayout.Alignment.LEADING,
										gl_gcmsPanel
												.createSequentialGroup()
												.addComponent(aPanel, javax.swing.GroupLayout.PREFERRED_SIZE,
														javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
												.addGap(0, 0, 0)
												.addComponent(bPanel, javax.swing.GroupLayout.PREFERRED_SIZE,
														javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
												.addGap(0, 0, 0)
												.addComponent(cPanel, javax.swing.GroupLayout.PREFERRED_SIZE,
														javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))));
		gl_gcmsPanel.setVerticalGroup(gl_gcmsPanel.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				gl_gcmsPanel
						.createSequentialGroup()
						.addComponent(showGcmsToggleButton1)
						.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
						.addGroup(
								gl_gcmsPanel
										.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
										.addComponent(bPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE)
										.addComponent(aPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE)
										.addComponent(cPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
												javax.swing.GroupLayout.PREFERRED_SIZE))
						.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
						.addComponent(Afield, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
								javax.swing.GroupLayout.PREFERRED_SIZE)
						.addGap(0, 0, 0)
						.addComponent(Bfield, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
								javax.swing.GroupLayout.PREFERRED_SIZE)
						.addGap(0, 0, 0)
						.addComponent(Cfield, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
								javax.swing.GroupLayout.PREFERRED_SIZE)));

		extractButton.setText("Extract");
		extractButton.setMargin(new Insets(2, 1, 2, 1));
		extractButton.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				extractButtonActionPerformed(evt);
			}
		});

		javax.swing.GroupLayout gl_leftPanel = new javax.swing.GroupLayout(leftPanel);
		gl_leftPanel.setHorizontalGroup(gl_leftPanel.createParallelGroup(Alignment.LEADING).addGroup(
				gl_leftPanel
						.createSequentialGroup()
						.addGroup(
								gl_leftPanel
										.createParallelGroup(Alignment.LEADING)
										.addComponent(optionsLabel)
										.addGroup(
												gl_leftPanel
														.createParallelGroup(Alignment.TRAILING, false)
														.addComponent(gcmsPanel, Alignment.LEADING, 0, 0, Short.MAX_VALUE)
														.addComponent(mousePanel, Alignment.LEADING, 0, 43, Short.MAX_VALUE)
														.addComponent(viewPanel, Alignment.LEADING, GroupLayout.DEFAULT_SIZE,
																GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)).addComponent(extractButton))
						.addContainerGap()));
		gl_leftPanel.setVerticalGroup(gl_leftPanel.createParallelGroup(Alignment.LEADING).addGroup(
				gl_leftPanel.createSequentialGroup().addComponent(optionsLabel).addPreferredGap(ComponentPlacement.RELATED)
						.addComponent(viewPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addPreferredGap(ComponentPlacement.RELATED)
						.addComponent(mousePanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addPreferredGap(ComponentPlacement.RELATED)
						.addComponent(gcmsPanel, GroupLayout.PREFERRED_SIZE, 45, GroupLayout.PREFERRED_SIZE)
						.addPreferredGap(ComponentPlacement.RELATED).addComponent(extractButton)));
		leftPanel.setLayout(gl_leftPanel);

		jScrollPane1.setViewportView(leftPanel);

		bottomPanel = new JPanel();
		FlowLayout fl_bottomPanel = (FlowLayout) bottomPanel.getLayout();
		fl_bottomPanel.setVgap(0);
		fl_bottomPanel.setHgap(0);

		pack();
	}// </editor-fold>//GEN-END:initComponents

	private void fixAxisButtonActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_fixAxisButtonActionPerformed
		fixAxis(fixAxisButton.isSelected());
	}// GEN-LAST:event_fixAxisButtonActionPerformed

	private void plsButtonActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_plsButtonActionPerformed
		showAllPeaklists = plsButton.isSelected();
		showAllPeaklistsToggle();
	}// GEN-LAST:event_plsButtonActionPerformed

	private void closingevent(javax.swing.event.InternalFrameEvent evt) {// GEN-FIRST:event_closingevent
		System.out.println("closing window");
		dsif.closeHeatmap();
	}// GEN-LAST:event_closingevent

	private void lichButtonActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_lichButtonActionPerformed

		if (lichButton.isSelected()) {
			System.out.println("Starting LiCh mode");
			DefaultCategoryDataset dataset = new DefaultCategoryDataset();

			Vector<String> ids = dsif.getMeasurementIds();
			int labelIndex = dsif.selectedLabel;
			int classIndex = dsif.selectedClasses;

			for (int j = 0; j < ids.size(); j++) {
				Double d = 0.0;
				String klass = "";
				if (classIndex != -1) {
					klass = dsif.table.getValueAt(j, classIndex) + "";
				}
				String xlabel = j + "";
				if (labelIndex != -1) {
					xlabel = dsif.table.getValueAt(j, labelIndex) + " (" + j + ")";
				}
				dataset.addValue(d, klass, xlabel);
			}
			LiCh = new ChartInternalFrame();
			LiCh.createChart(dataset);
			BaseFrame.applyFrame(LiCh);
			LiCh.moveToFront();
		} else {
			LiCh.dispose();
		}
	}// GEN-LAST:event_lichButtonActionPerformed

	public void gcmsFilesDropped(Vector<String> filenames) {
		gcmsFilenames = filenames;
	}

	private void optionsLabelMouseClicked(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_optionsLabelMouseClicked
		JLabel temp = optionsLabel;
		optionsPopupMenu.show(temp, 0, temp.getHeight());
	}// GEN-LAST:event_optionsLabelMouseClicked

	private void MenuItem0010ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_MenuItem0010ActionPerformed
		noiseLevel = 0.0010;
		BUFFER = false;
		validCacheObjectFound = false;
		updateHeatmap();
		BUFFER = true;
		saveToCache();
	}// GEN-LAST:event_MenuItem0010ActionPerformed

	private void MenuItem0015ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_MenuItem0015ActionPerformed
		noiseLevel = 0.0015;
		BUFFER = false;
		validCacheObjectFound = false;
		updateHeatmap();
		BUFFER = true;
		saveToCache();
	}// GEN-LAST:event_MenuItem0015ActionPerformed

	private void MenuItem0020ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_MenuItem0020ActionPerformed
		noiseLevel = 0.0020;
		BUFFER = false;
		validCacheObjectFound = false;
		updateHeatmap();
		BUFFER = true;
		saveToCache();
	}// GEN-LAST:event_MenuItem0020ActionPerformed

	private void MenuItem0025ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_MenuItem0025ActionPerformed
		noiseLevel = 0.0025;
		BUFFER = false;
		validCacheObjectFound = false;
		updateHeatmap();
		BUFFER = true;
		saveToCache();
	}// GEN-LAST:event_MenuItem0025ActionPerformed

	private void MenuItem0030ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_MenuItem0030ActionPerformed
		noiseLevel = 0.0030;
		BUFFER = false;
		validCacheObjectFound = false;
		updateHeatmap();
		BUFFER = true;
		saveToCache();
	}// GEN-LAST:event_MenuItem0030ActionPerformed

	private void MenuItem0005ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_MenuItem0005ActionPerformed
		noiseLevel = 0.0005;
		BUFFER = false;
		validCacheObjectFound = false;
		updateHeatmap();
		BUFFER = true;
		saveToCache();
	}// GEN-LAST:event_MenuItem0005ActionPerformed

	private void MenuItem0000ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_MenuItem0000ActionPerformed
		noiseLevel = 0.0000;
		BUFFER = false;
		validCacheObjectFound = false;
		updateHeatmap();
		BUFFER = true;
		saveToCache();
	}// GEN-LAST:event_MenuItem0000ActionPerformed

	private void showGcmsToggleButton1ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_showGcmsToggleButton1ActionPerformed
		showGcms = showGcmsToggleButton1.isSelected();
		updateHeatmap();
	}// GEN-LAST:event_showGcmsToggleButton1ActionPerformed

	private void showHeatmapOnlyMenuItemActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_showHeatmapOnlyMenuItemActionPerformed
		showHeatmapOnly = showHeatmapOnlyMenuItem.isSelected();
		showSpectraOnMouseover = !showHeatmapOnly;
		updateHeatmap();
	}// GEN-LAST:event_showHeatmapOnlyMenuItemActionPerformed

	private void identifyMccImsPeaksMenuItemActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_identifyMccImsPeaksMenuItemActionPerformed
		Peaklist pl = idataset.peaklists.get(measurement.measurementID);
		for (Peak p : pl.getPeaks()) {
			for (SubstanceDBItem s : SubstanceDB.substances) {
				double rtTol = s.RtMcc * 0.15 + 4;
				double dtTol = 0.008;
				if (Math.abs(p.rt - s.RtMcc) < rtTol && Math.abs(p.dt - s.k0Monomer) < dtTol) {
					String[] substanceParameter = new String[] { s.name, s.k0Monomer + "", s.RtMcc + "", dtTol + "", rtTol + "" };

					boolean substanceAlreadyExists = false;
					for (SubstanceInfo si : idataset.substanceInfos) {
						if (s.name.equals(si.name)) {
							substanceAlreadyExists = true;
						}
					}
					if (!substanceAlreadyExists) {
						SubstanceInfo si = new SubstanceInfo(substanceParameter);
						si.RtGc = s.RtGc;
						idataset.addSubstanceInfo(si);
					}

				}
			}
		}
		dsif.updateTable();
		updateHeatmap();
	}// GEN-LAST:event_identifyMccImsPeaksMenuItemActionPerformed

	private void identifyMccImsPeaksMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_identifyMccImsPeaksMenuItem1ActionPerformed
		Peaklist pl = idataset.peaklists.get(measurement.measurementID);

		for (Peak p : pl.getPeaks()) {
			Vector<SubstanceDBItem> matchingSubstanceDBItems = new Vector<SubstanceDBItem>();
			for (SubstanceDBItem s : SubstanceDB.substances) {
				double rtTol = s.RtMcc * 0.15 + 4;
				double dtTol = 0.008;
				if (Math.abs(p.rt - s.RtMcc) < rtTol && Math.abs(p.dt - s.k0Monomer) < dtTol) {
					matchingSubstanceDBItems.add(s);
				}
			}
			if (matchingSubstanceDBItems.size() == 1) {
				SubstanceDBItem s = matchingSubstanceDBItems.get(0);
				double rtTol = s.RtMcc * 0.15 + 4;
				double dtTol = 0.008;
				String[] substanceParameter = new String[] { s.name, s.k0Monomer + "", s.RtMcc + "", dtTol + "", rtTol + "" };

				boolean substanceAlreadyExists = false;
				for (SubstanceInfo si : idataset.substanceInfos) {
					if (s.name.equals(si.name)) {
						substanceAlreadyExists = true;
					}
				}

				if (!substanceAlreadyExists) {
					SubstanceInfo si = new SubstanceInfo(substanceParameter);
					si.RtGc = s.RtGc;
					idataset.addSubstanceInfo(si);
				}
			} else if (matchingSubstanceDBItems.size() > 1) {
				SubstanceDBItem bestSubstance = null;
				double bestDistance = 9999;
				for (SubstanceDBItem s : matchingSubstanceDBItems) {
					if (Math.abs(p.dt - s.k0Monomer) < bestDistance) {
						bestSubstance = s;
						bestDistance = Math.abs(p.dt - s.k0Monomer);
					}
				}
				SubstanceDBItem s = bestSubstance;
				double rtTol = s.RtMcc * 0.15 + 4;
				double dtTol = 0.008;
				String[] substanceParameter = new String[] { s.name, s.k0Monomer + "", s.RtMcc + "", dtTol + "", rtTol + "" };
				boolean substanceAlreadyExists = false;
				for (SubstanceInfo si : idataset.substanceInfos) {
					if (s.name.equals(si.name)) {
						substanceAlreadyExists = true;
					}
				}
				if (!substanceAlreadyExists) {
					SubstanceInfo si = new SubstanceInfo(substanceParameter);
					si.RtGc = s.RtGc;
					idataset.addSubstanceInfo(si);
				}
			}

		}
		dsif.updateTable();
		updateHeatmap();
	}// GEN-LAST:event_identifyMccImsPeaksMenuItem1ActionPerformed

	private void clearMovingAnnotation() {
		substanceEditingProcess = false;
		try {
			heatmapPlot.removeAnnotation(movingTextannotation);
		} catch (Exception x) {
		}
		try {
			heatmapPlot.removeAnnotation(movingtop);
			heatmapPlot.removeAnnotation(movingbot);
			heatmapPlot.removeAnnotation(movinglef);
			heatmapPlot.removeAnnotation(movingrig);
		} catch (Exception exc) {
		}

		showSubstanceInfos();
	}

	private void noneButtonActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_noneButtonActionPerformed
		clearMovingAnnotation();
		this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
	}// GEN-LAST:event_noneButtonActionPerformed

	private void deleteAreaMenuItemActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_deleteAreaMenuItemActionPerformed
		idataset.substanceInfos.remove(mouseOveredSubstance);
		dsif.updateTable();
	}// GEN-LAST:event_deleteAreaMenuItemActionPerformed

	private void addPeakActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_addPeakActionPerformed
		clearMovingAnnotation();
		this.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
	}// GEN-LAST:event_addPeakActionPerformed

	private void deletePeakActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_deletePeakActionPerformed
		clearMovingAnnotation();
		this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
	}// GEN-LAST:event_deletePeakActionPerformed

	private void moveAreaActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_moveAreaActionPerformed
		clearMovingAnnotation();
		this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
	}// GEN-LAST:event_moveAreaActionPerformed

	private void addSubstanceActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_addSubstanceActionPerformed
		this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
	}// GEN-LAST:event_addSubstanceActionPerformed

	private void deleteSubstanceActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_deleteSubstanceActionPerformed
		this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
	}// GEN-LAST:event_deleteSubstanceActionPerformed

	private void extractButtonActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_extractButtonActionPerformed
		if (extractedSpectraChart != null) {
			if (!extractedSpectraChart.isVisible()) {
				extractedSpectraChart = null;
			}
		}
		if (extractedSpectraChart == null) {
			extractedSpectraChart = new ChartInternalFrame();
			extractedSpectraChart.disableChartTypeButtons();
			BaseFrame.applyFrame(extractedSpectraChart);
			extractedSpectraChart.setVisible(true);
			extractedSpectraChart.moveToFront();

		}

		for (Object o : ((XYSeriesCollection) spectraplot.getDataset()).getSeries()) {
			XYSeries s = ((XYSeries) o);
			s.setKey(s.getDescription() + " " + s.getKey());
			extractedSpectraChart.lineDataset.addSeries(s);

		}
		extractedSpectraChart.showLineDatasetAsLineChart();
		extractedSpectraChart.updateUI();

	}// GEN-LAST:event_extractButtonActionPerformed

	private void PolarGlyphMenuItemActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_PolarGlyphMenuItemActionPerformed

		if (PolarGlyphMenuItem.isSelected()) {
			for (SubstanceInfo substanceInfo : idataset.substanceInfos) {
				Vector<Double> sub = dsif.getColumnForSubstance(substanceInfo.name);
				Vector<String> cls = dsif.getColumnAt(dsif.selectedClasses);
				Vector<String[]> glyphData = new Vector<String[]>(sub.size());
				for (int i = 0; i < cls.size(); i++) {
					glyphData.add(i, new String[] { cls.get(i), sub.get(i) + "" });
				}
				Image glyphImage = PolarGlyphBuilder.getPolarGlyphImage(glyphData, 400);
				XYImageAnnotation glyphAnnotation = new XYImageAnnotation(substanceInfo.dt, substanceInfo.rt, glyphImage);
				heatmapPlot.addAnnotation(glyphAnnotation);
			}
		} else {
			for (Object annotation : heatmapPlot.getAnnotations()) {
				if (annotation instanceof XYImageAnnotation) {
					heatmapPlot.removeAnnotation((XYImageAnnotation) annotation);
				}
			}
		}
	}// GEN-LAST:event_PolarGlyphMenuItemActionPerformed

	private void keyReleased(java.awt.event.KeyEvent evt) {// GEN-FIRST:event_keyReleased

		if (evt.getKeyCode() == 38) {
			int y = dsif.table.getSelectedRow();
			int x = dsif.table.getSelectedColumn();
			if (y - 1 >= 0) {
				dsif.table.changeSelection(y - 1, x, false, false);
				dsif.showHeatmap();
			} else {
				System.out.println("First row reached, can't go up");
			}
		}
		if (evt.getKeyCode() == 40) {
			int y = dsif.table.getSelectedRow();
			int x = dsif.table.getSelectedColumn();
			if (y + 1 < dsif.table.getRowCount()) {
				dsif.table.changeSelection(y + 1, x, false, false);
				dsif.showHeatmap();
			} else {
				System.out.println("Last row reached, can't go down");
			}

		}
	}// GEN-LAST:event_keyReleased

	private void updateMenuItemActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_updateMenuItemActionPerformed
		BUFFER = false;
		validCacheObjectFound = false;
		if (!ripCompensation) {
			amplify = 1;
		} else {
			amplify = 40;
		}
		updateHeatmap();
		BUFFER = true;
	}// GEN-LAST:event_updateMenuItemActionPerformed

	private void determNoiseLevelMenuItemActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_determNoiseLevelMenuItemActionPerformed
		ArrayList<Double> preRips = ImageMethods.getPreRipValues(ImageMethods.lastMap, scaleK0, scaleRT);
		MyMath.statisticValues(preRips);

	}// GEN-LAST:event_determNoiseLevelMenuItemActionPerformed

	private void aPlusActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_aPlusActionPerformed
		Range r = gcmsPlot.getDomainAxis().getRange();
		A *= 1.01;
		Afield.setText(new DecimalFormat("0.000").format(A));
		updateHeatmap();
		gcmsPlot.getDomainAxis().setRange(r);
	}// GEN-LAST:event_aPlusActionPerformed

	private void aMinusActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_aMinusActionPerformed
		Range r = gcmsPlot.getDomainAxis().getRange();
		A *= 0.99;
		Afield.setText(new DecimalFormat("0.000").format(A));
		updateHeatmap();
		gcmsPlot.getDomainAxis().setRange(r);
	}// GEN-LAST:event_aMinusActionPerformed

	private void bPlusActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_bPlusActionPerformed
		Range r = gcmsPlot.getDomainAxis().getRange();
		B *= 1.01;
		Bfield.setText(new DecimalFormat("0.000").format(B));
		updateHeatmap();
		gcmsPlot.getDomainAxis().setRange(r);
	}// GEN-LAST:event_bPlusActionPerformed

	private void bMinusActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_bMinusActionPerformed
		Range r = gcmsPlot.getDomainAxis().getRange();
		B *= 0.99;
		Bfield.setText(new DecimalFormat("0.000").format(B));
		updateHeatmap();
		gcmsPlot.getDomainAxis().setRange(r);
	}// GEN-LAST:event_bMinusActionPerformed

	private void cPlusActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_cPlusActionPerformed
		Range r = gcmsPlot.getDomainAxis().getRange();
		C *= 1.01;
		Cfield.setText(new DecimalFormat("0.000").format(C));
		updateHeatmap();
		gcmsPlot.getDomainAxis().setRange(r);
	}// GEN-LAST:event_cPlusActionPerformed

	private void cMinusActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_cMinusActionPerformed
		Range r = gcmsPlot.getDomainAxis().getRange();
		C *= 0.99;
		Cfield.setText(new DecimalFormat("0.000").format(C));
		updateHeatmap();
		gcmsPlot.getDomainAxis().setRange(r);
	}// GEN-LAST:event_cMinusActionPerformed

	private void greyScaleActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_greyScaleActionPerformed
		updateHeatmap();
	}// GEN-LAST:event_greyScaleActionPerformed
		// Variables declaration - do not modify//GEN-BEGIN:variables

	private javax.swing.JTextField Afield;
	private javax.swing.JTextField Bfield;
	private javax.swing.JTextField Cfield;
	private javax.swing.JMenuItem MenuItem0000;
	private javax.swing.JMenuItem MenuItem0005;
	private javax.swing.JMenuItem MenuItem0010;
	private javax.swing.JMenuItem MenuItem0015;
	private javax.swing.JMenuItem MenuItem0020;
	private javax.swing.JMenuItem MenuItem0025;
	private javax.swing.JMenuItem MenuItem0030;
	private javax.swing.JCheckBoxMenuItem PolarGlyphMenuItem;
	private javax.swing.JMenu SubstanceDBMenu;
	private javax.swing.JButton aMinus;
	private javax.swing.JButton aPlus;
	public javax.swing.JToggleButton addPeak;
	public javax.swing.JToggleButton addSubstance;
	private javax.swing.JLabel alignRTValueLabel;
	private javax.swing.JPopupMenu areaOnHeatmapMenu;
	private javax.swing.JButton bMinus;
	private javax.swing.JButton bPlus;
	private javax.swing.ButtonGroup buttonGroup1;
	private javax.swing.JButton cMinus;
	private javax.swing.JButton cPlus;
	private javax.swing.JPanel center;
	private javax.swing.JCheckBoxMenuItem closeareaOnHeatmap;
	private javax.swing.JMenuItem deleteAreaMenuItem;
	public javax.swing.JToggleButton deletePeak;
	public javax.swing.JToggleButton deleteSubstance;
	private javax.swing.JMenuItem determNoiseLevelMenuItem;
	private javax.swing.JButton extractButton;
	private javax.swing.JMenu filterMenu;
	private javax.swing.JToggleButton fixAxisButton;
	private javax.swing.JCheckBoxMenuItem gaussFilter;
	private javax.swing.JCheckBoxMenuItem greyScale;
	private javax.swing.JLabel heatLabel;
	private javax.swing.JMenuItem identifyMccImsPeaksMenuItem;
	private javax.swing.JMenuItem identifyMccImsPeaksMenuItem1;
	private javax.swing.JLabel jLabel1;
	private javax.swing.JLabel jLabel2;
	private javax.swing.JLabel jLabel3;
	private javax.swing.JPanel mousePanel;
	private javax.swing.JPanel viewPanel;
	private javax.swing.JPanel gcmsPanel;
	private javax.swing.JPanel aPanel;
	private javax.swing.JPanel bPanel;
	private javax.swing.JPanel cPanel;
	private javax.swing.JScrollPane jScrollPane1;
	private javax.swing.JSeparator jSeparator1;
	public javax.swing.JToggleButton lichButton;
	public javax.swing.JCheckBoxMenuItem livePolarGlyphMenuItem;
	private javax.swing.JCheckBoxMenuItem medianFilter;
	public javax.swing.JToggleButton moveArea;
	private javax.swing.JMenu noiseLevelMenu;
	private javax.swing.JToggleButton noneButton;
	private javax.swing.JLabel optionsLabel;
	private javax.swing.JPopupMenu optionsPopupMenu;
	private javax.swing.JToggleButton plsButton;
	private javax.swing.JCheckBoxMenuItem ripCompensationCheckBox;
	private javax.swing.JCheckBoxMenuItem sgFilter;
	private javax.swing.JToggleButton showGcmsToggleButton1;
	private javax.swing.JCheckBoxMenuItem showHeatmapOnlyMenuItem;
	private javax.swing.JCheckBoxMenuItem showPeaklistCheckBox;
	private javax.swing.JCheckBoxMenuItem showSubstanceAnnotationsCheckBox;
	private javax.swing.JMenuItem updateMenuItem;
	private JPanel bottomPanel;
	private JLabel lblRipPosition;
	private JLabel alignK0ValueLabel;
	private JPanel leftPanel;
}
